//
//  ViewController.m
//  GZJsonValue
//
//  Created by GR on 2018/12/18.
//  Copyright © 2018 GR. All rights reserved.
//

#import "ViewController.h"
//#import "NSDictionary+HMSJSON.h"

#import "NSDictionary+GZJosnValue.h"
#import "NSArray+GZJsonValue.h"
#import "GZJsonValue.h"

@interface User: NSObject

@property (nonatomic, copy)     NSString *name;
@property (nonatomic, assign)   NSInteger age;
@property (nonatomic, copy)     NSString *job;
@property (nonatomic, copy)     NSDate *birthday;
@property (nonatomic, copy)     NSDate *graduateschool;
@end

@implementation User
- (NSString *)description {
    
    NSMutableString *string = [NSMutableString stringWithString:@"\n"];
    [string appendString:@"<"];
    [string appendFormat:@"%@: %p", self.class, self];
    [string appendString:@"\n"];
    [string appendFormat:@"name: %@\n",self.name];
    [string appendFormat:@"age : %zd\n",self.age];
    [string appendFormat:@"job: %@\n",self.job];
    [string appendFormat:@"birthday: %@\n",self.birthday];
    [string appendFormat:@"graduateschool: %@",self.graduateschool];
    [string appendString:@">"];
    
    return string;
}
@end

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    User *user = [User new];
    
    NSDictionary *dic   = @{ @"age": @"jsonvalue",
                           @"name": @"xtg",
                             @"birthday": @1546936500,
                             @"graduateschool": @"2011.11.12"
                           };
    NSArray *jobs       = @[ @{ @"address": @"xxxxx",
                                @"name": @"huami"
                                },
                             @{ @"address": @"yyyyy",
                                @"name": @"timeface"
                                }];
    
    
    user.name = dic.json[@"name"].string;
    user.age  = dic.json[@"age"].integerValue;
    user.job  = jobs.json[0][@"name"].string;
    user.birthday = dic.json[@"birthday"].date;
    user.graduateschool = dic.json[@"graduateschool"].dateFormat(@"yyyy.MM.dd");
    NSLog(@"%@",dic.json[@"age"].number);
    
//    NSNumber *number = dic.hmjson[@"age"].number;
//
//    NSLog(@"number = %@", number.doubleValue);
}


@end
